<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>18-v-for循环</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <style></style>
  </head>
  <body>
    <div id="app">
      <ul>
        <li v-if="flag === true" v-for="(item, index) in arr">{{item}}</li>
        <h3 v-else>水果卖完了！</h3>
      </ul>
      <button @click="btn">新品上架</button>
    </div>
    <script>
      var vm = new Vue({
        el: '#app',
        data: {
          arr: ['橘子', '香蕉', '荔枝'],
          flag: false,
        },
        methods: {
          btn: function () {
            this.flag = !this.flag;
          },
        },
      });
    </script>
  </body>
</html>
